package cn.iocoder.yudao.module.javainfo.dal.mysql.userpet;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.javainfo.dal.dataobject.userpet.UserPetDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.javainfo.controller.admin.userpet.vo.*;

/**
 * 用户宠物关联 Mapper
 *
 * @author 爪哇国大BOSS
 */
@Mapper
public interface UserPetMapper extends BaseMapperX<UserPetDO> {

    default PageResult<UserPetDO> selectPage(UserPetPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UserPetDO>()
                .eqIfPresent(UserPetDO::getUserId, reqVO.getUserId())
                .eqIfPresent(UserPetDO::getPetId, reqVO.getPetId())
                .betweenIfPresent(UserPetDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(UserPetDO::getId));
    }

    default void deleteByPetId(Long id){
        delete(new LambdaQueryWrapperX<UserPetDO>().eq(UserPetDO::getPetId, id));
    };

    default void deleteByPetIds(List<Long> ids){
        delete(new LambdaQueryWrapperX<UserPetDO>().in(UserPetDO::getPetId, ids));
    };

    default UserPetDO selectByPetId(Long id){
        return selectOne(UserPetDO::getPetId, id);
    }
}